﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ERPStudio;
using System.Data.SqlClient;

namespace ResUma
{
    public partial class GrilaOcupatiiFrm : FrmRezumat
    {
        protected int _IDTipSpor = -1;
        public GrilaOcupatiiFrm(ModuleClass mc,int idtipspor):base(mc)
        {
            _IDTipSpor = idtipspor;
            InitializeComponent();
            workConnString = mc.workConnectionString;
            ActiveControl = grileOcupatiiDGV;
            grileOcupatiiDGV.m_AutoCompletionColumns.Add(OcupatieColumn);
        }

        
        private void GrilaOcupatiiFrm_Load(object sender, EventArgs e)
        {
            SqlConnection con = DeschideConexiune(workConnString);

            Object ret = GetSetupValue("ResUmaSetup", "VersiuneCOR", ModuleInfo.CodUnitate, con);
            Int16 versiuneCOR = Convert.ToInt16(ret);

            this.ocupatiiTableAdapter.Connection = con;
            this.ocupatiiTableAdapter.FillByTerminalVersiune(this.eSRPDataSet.Ocupatii,versiuneCOR);
            this.grileOcupatiiTableAdapter.Connection = con;
            if (_IDTipSpor == -1)
                this.grileOcupatiiTableAdapter.Fill(this.eSRPDataSet.GrileOcupatii);
            else
            {
                this.grileOcupatiiTableAdapter.FillByIDSpor(this.eSRPDataSet.GrileOcupatii, _IDTipSpor);
                //IDTipSporColumn.Visible = false;
                eSRPDataSet.GrileOcupatii.IDTipSporColumn.DefaultValue = _IDTipSpor;
            }
            InchideConexiune(con);
            AddBindingSource(grileOcupatiiBindingSource);
            listTableAdaptor.Add(grileOcupatiiTableAdapter.Adapter);
            HandleSalvare += Salvare;
        }
    }
}
